import java.util.Arrays;
public class Test {
    public static void main1(String[] args) {
        int[][] array1 = {{1,2,3},{4,5,6}};
        int[][] array2 = new int[][]{{1,2,3},{4,5,6}};
        int[][] array3 = new int[2][3];//默认6个0
    }

    public static void main2(String[] args) {
        int[][] array1 = {{1,2,3},{4,5,6}};
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) {
                System.out.print(array1[i][j]+" ");
            }
            System.out.println();
        }
    }

    public static void main3(String[] args) {
        int[][] array1 = {{1,2,3},{4,5,6}};
        for (int i = 0; i < array1.length; i++) {
            for (int j = 0; j < array1[i].length; j++) {
                System.out.print(array1[i][j]+" ");
            }
            System.out.println();
        }
        System.out.println(Arrays.deepToString(array1));//打印二维数组
        /*System.out.println(array1[0]); // 打印地址
        System.out.println(array1[1]);  // 打印地址
        System.out.println("==========");
        System.out.println(Arrays.toString(array1[0])); //1 2 3
        System.out.println(Arrays.toString(array1[1])); //4 5 6
        System.out.println("==========");
        System.out.println(array1[0].length);//3
        System.out.println(array1[1].length);//3
        System.out.println("==========");
        System.out.println(array1.length); //2   */
    }
    public static void main10(String[] args) {
        //不规则的二维数组
        int[][] array1 = new int[2][];
        /*array3[0] = new int[]{1,2,3};
        array3[1] = new int[]{4,5,6,7,8,9};*/
        //System.out.println(Arrays.deepToString(array3));

        for (int i = 0; i < array1.length; i++) {
            for (int j = 0; j < array1[i].length; j++) {
                System.out.print(array1[i][j]+" ");//空指针异常
            }
            System.out.println();
        }
    }

    public static void main11(String[] args) {
        //通过new关键字 实例化了一个Dog对象！
        Dog dog = new Dog();
        //dog就是一个引用 指向了Dog对象
        dog.name = "初一";
        dog.age = 10;
        dog.color = "黄色";
        System.out.println(dog.name);
        System.out.println(dog.age);
        System.out.println(dog.color);

        dog.eat();
        dog.bark();
        System.out.println("===========");
        Dog dog2 = new Dog();
        //dog就是一个引用 指向了Dog对象
        dog2.name = "初二";
        dog2.age = 12;
        dog2.color = "黑色";
        System.out.println(dog2.name);
        System.out.println(dog2.age);
        System.out.println(dog2.color);

        dog2.eat();
        dog2.bark();

    }
    public static void main(String[] args) {
        Date date = new Date();
        date.setDate(2008,8,8);
        date.printDate();
        System.out.println("============");
        Date date2 = new Date();
        //setDate方法里面的this 就是谁调用过了这个方法
        date2.setDate(2009,9,9);
        date2.printDate();
    }
}

class WashMachine {
    //成员属性/字段 ： 是定义在类里边 方法的外边
    public String brand; // 品牌
    public String type; // 型号
    public double weight; // 重量
    public double length; // 长
    public double width; // 宽
    public double height; // 高
    public String color; // 颜色

    /*public void func() {
        int a = 10;//局部变量
    }*/

    //行为/成员方法：
    public void washClothes(){ // 洗衣服
        System.out.println("洗衣功能");
    }

    public void dryClothes(){ // 脱水
        System.out.println("脱水功能");
    }

    public void setTime(){ // 定时
        System.out.println("定时功能");
    }
}

class Dog {
    public String name;
    public int age;
    public String color;

    public void eat() {
        System.out.println(name+"吃饭！");
    }

    public void bark() {
        System.out.println(name+"旺旺叫！");
    }
}

class Date {
    public int year;
    public int month;
    public int day;

    /*public void setDate(int y,int m,int d) {
        year = y; //通过方法给3个属性赋值
        month = m;
        day = d;
    }*/

    public void setDate(/*Date this,*/int year,int month,int day) {
        this.year = year;//this代表当前对象的引用
        this.month = month;
        this.day = day;
    }

    public void printDate() {
        System.out.println("年："+ this.year+" 月："
                +this.month+" 日："+this.day);
    }
}